package com.yanqu.road.server.cmd.zhaoshang;

import com.yanqu.road.pb.zhaoshang.ZhaoShangProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.zhaoshang.ZsMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;

@Cmd(code = CrossProtocol.C2_ZHAO_SHANG_PROJECT_LIST, desc = "项目列表")
public class ZsProjectListCmd  extends CrossCommand {

    private long searchUserAliasId;
    private int listSizeLimit;
    private int templateId = -1;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ZhaoShangProto.CrossZsProjectListReqMsg reqMsg = ZhaoShangProto.CrossZsProjectListReqMsg.parseFrom(packet.getBytes());
        searchUserAliasId = reqMsg.getSearchUserAliasId();
        listSizeLimit = reqMsg.getListNumLimit();
        if(reqMsg.hasTemplateId()){
            templateId = reqMsg.getTemplateId();
        }
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        ZsMgr.listProjects(searchUserAliasId, serverId, packet.getPlayerId(), listSizeLimit, templateId);
    }

    @Override
    public void sendData() {

    }
}
